Rust: Make impl blocks only give rise to direct trait implementation#20723
Merged
hvitved merged 4 commits intogithub:mainfrom Nov 17, 2025
Merged
Rust: Make impl blocks only give rise to direct trait implementation#20723hvitved merged 4 commits intogithub:mainfrom
hvitved merged 4 commits intogithub:mainfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR changes how we calculate the trait/implements hierarchy.
Currently an
impl Trait for Tblock makesTdirectly implement bothTraitand any supertraits,SuperTrait, ofTrait. However, in order for thisimplblock to be valid, it must already be the case thatTimplementsSuperTraitby some otherimplblock. Hence, the only new information from animplblock is the implementation of the specific target trait.This PR changes how we handle
implblocks when calculating the trait/implements hierarchy, s.t.implblocks only makes a type implement the specific trait in theimplblock.This restriction is also used in
AssocFunctionTypewhere the restriction removes some spurious call targets.The DCA report shows a small speedup and decent reductions in "Path resolution inconsistencies" and "Nodes With Type At Length Limit". There is a small increase in "Unknown expression types". I think this increase looks reasonable when compared to the decrease in "Path resolution inconsistencies". I also did a quick and small spot check on
neon, and the lost types all looked like spurious types.